<div class="widget modal" id="simpledialog">
	<header><h2>Thông báo hệ thống</h2></header>
	<section>
		<p>
			Bạn thực sự muốn xóa?
		</p>

		<!-- yes/no buttons -->
		<p>
			<button class="button button-blue close">Đồng ý</button>
			<button class="button button-gray close">Hủy</button>
		</p>
	</section>
</div>
<div class="container_8 clearfix">                
	<!-- Main Section -->
	<section class="main-section grid_8">
	<!-- Tables Section -->
	<div class="main-content">
		<header>
			<h2>Danh sách các slide của website</h2>
		</header>
		<section class="with-table">
			<table id="TablePaginate" class="datatable tablesort selectable paginate full">
				<thead>
					<tr>
						<th style="width: 100px;">Tên slide</th>
						<th style="width: 250px;">Ảnh</th>
						<th style="width: 40px;">Vị trí</th>
						<th style="width: 90px;">Loại slide</th>
						<th style="width: 80px">Lựa chọn</th>
					</tr>
				</thead>
				<tfoot>
					<tr>
						<th>Tên slide</th>
						<th>Ảnh</th>
						<th>Vị trí</th>
						<th>Loại slide</th>
						<th>Lựa chọn</th>
					</tr>
				</tfoot>
				<tbody>
			<?php
				foreach ($this->slideList as $slide)
				{
			?>
					<tr>
						<td><?php echo $slide['name']?></td>
						<td><img src="<?php echo $slide['image']?>" width="400" /></td>
						<td><?php echo $slide['position']?></td>
						<td><?php if($slide['homepage'] == "0") echo "Slide trang SP"; else echo "Slide trang chủ"; ?></td>
						<td>
							<a href="<?php echo $this->url->action("edit",array($slide['id']));?>">Sửa</a>/ 
							<a onclick="confirmDelete(this);" class="modalInput" rel="#simpledialog" accesskey="<?php echo $slide['id']?>" ajaxify="<?php echo $this->url->action("delete")?>">Xóa</a>
						</td>
					</tr>
					<?php }?>
				</tbody>
			</table>
			<div id='pager' class='pager'>
				<li><a href='#' alt='Previous' class='prevPage button-blue'>Trước</a></li>
				<span class='listPages'></span>
				<li><a href='#' alt='Next' class='nextPage button-blue'>Kế tiếp</a></li>
				<span class="button-blue" style='float:right; height: 20px; padding: 0 5px 0 5px;'>Đang xem <span class='currentPage'></span> của <span class='totalPages'></span></span>
			</div>
		</section>
	</div>
	<!-- End Tables Section -->
	</section>
	<!-- Main Section End -->
</div>
<script type="text/javascript">
$(document).ready(function(){
    /**
     * Modal Dialog Boxes Setup
     */
	$(".modalInput").overlay({

        // some mask tweaks suitable for modal dialogs
        mask: {
            color: '#000',
            loadSpeed: 200,
            opacity: 0.5
        },

        closeOnClick: false
    });

	//Table pagging - sort
	$('#TablePaginate').paginateTable({ rowsPerPage: 10 });
	$('#TablePaginate').tablesort();
});
function confirmDelete(obj) {
    /* Simple Modal Box */
    var buttons1 = $("#simpledialog button").click(function(e) {
	
        // get user input
        var yes = buttons1.index(this) === 0;

        if (yes) {
            $.post($(obj).attr("ajaxify"),{id: $(obj).attr("accessKey")}, function(response){
		   		if(response.success)
		   		{
					$(obj).parents("tr").remove();
			   	}
           }, "json");
        }
    });
}
</script>